package model.board;

import java.sql.SQLException;
import java.util.HashMap;
import java.util.List;

import com.ibatis.sqlmap.client.SqlMapClient;

public class FreeBoardDao {
	private SqlMapClient sqlMapClient;

	public FreeBoardDao() {
		super();
	}

	public FreeBoardDao(SqlMapClient sqlMapClient) {
		super();
		this.sqlMapClient = sqlMapClient;
	}

	public int freeWrite(FreeBoardVO bvo) throws SQLException {
		int num=(Integer) sqlMapClient.insert("freeBoard.freeWrite",bvo);
		System.out.println("dao num:"+num);
		return num;
	}
	public String selectByNoForDate(int no) throws SQLException {
		return (String) sqlMapClient.queryForObject("freeBoard.selectByNoForDate",no);
	}
	public List<FreeBoardVO> getContentList(HashMap map) throws SQLException {
		return sqlMapClient.queryForList("freeBoard.getContentList",map);
	}
	public int totalContent() throws SQLException {
		return (Integer)sqlMapClient.queryForObject("freeBoard.totalContent");
	}
	public void updateCount(int bno) throws SQLException {
		sqlMapClient.update("freeBoard.updateCount", bno);
	}
	public FreeBoardVO showContent(int bno) throws SQLException {
		return (FreeBoardVO)sqlMapClient.queryForObject("freeBoard.showContent",bno);
	}
	public void deleteContent(int bno) throws SQLException {
		sqlMapClient.delete("freeBoard.deleteContent",bno);
	}
	public void freeUpdateContent(FreeBoardVO bvo) throws SQLException {
		sqlMapClient.update("freeBoard.freeUpdateContent",bvo);
	}
	public void freeUpdateRestep(int ref, int restep) throws SQLException { 
		HashMap map = new HashMap();
		map.put("b_ref", ref);
		map.put("b_restep", restep);
		sqlMapClient.update("freeBoard.freeUpdateRestep", map);
	}
	public int freeInsertRefContent(FreeBoardVO fvo) throws SQLException {
		return (Integer) sqlMapClient.insert("freeBoard.freeWriteRef", fvo); 
	}
	public List freeSearch(HashMap map) throws SQLException {
		return sqlMapClient.queryForList("freeBoard.freeSearch",map);
	} 
	public int freeTotalContentBySearch(FreeBoardVO vo) throws SQLException {
		return (Integer) sqlMapClient.queryForObject("freeBoard.freeTotalContentBySearch",vo);
	}

	public int freeInsertReply(BoardReplyVO brvo) throws SQLException { 
		return (Integer) sqlMapClient.insert("freeBoard.freeInsertReply",brvo);
	}
	public List freeAllReply(int bno1) throws SQLException {
		return sqlMapClient.queryForList("freeBoard.freeAllReply",bno1); 
	}

	public void freeDelReply(String board_no) throws SQLException {
		sqlMapClient.delete("freeBoard.freeDelReply",board_no);
	}
	public void updateReplyCount(int b_no) throws SQLException {
		sqlMapClient.update("freeBoard.updateReplyCount", b_no);
		
	}
	public void deleteReplyCount(int b_no) throws SQLException {
		sqlMapClient.update("freeBoard.deleteReplyCount", b_no);
	}

	public void deleteRef(int bno) throws SQLException {
		sqlMapClient.delete("freeBoard.deleteRef",bno);
		
	}
}
